package sk.tuke.lara.masplc.agents;

import jade.core.Agent;
import jade.lang.acl.ACLMessage;
import sk.tuke.lara.masplc.Conversations;

public class OperatorAgent extends Agent {

    private static final long serialVersionUID = -4002907714636837840L;
    private OperatorGui operatorGui;

    @Override
    protected void setup() {
        System.out.println("operator created");
        addBehaviour(new OperatorControlToBehaviour(this));
        operatorGui = new OperatorGui(this);
        operatorGui.showGui();
    }

    @Override
    protected void takeDown() {
        operatorGui.dispose();
        System.out.println("operator cleaned");
    }

    public void initiateControl(int pozadovanaHodnotaVykonu) {
        ACLMessage msg = new ACLMessage(ACLMessage.REQUEST);
        msg.setConversationId(Conversations.INITIATE_CONTROL);
        msg.setContent(String.valueOf(pozadovanaHodnotaVykonu));
        msg.addReceiver(getAID());
        send(msg);
    }

}
